package com.panda.mall.common.mallOrder.enums;

import com.panda.mall.common.base.EnumInterface;
import lombok.Getter;

/**
 * author: tcy
 * description:订单状态枚举
 */
public enum OrderStatusEnum implements EnumInterface {

    WAITPAY("waitPay",0,"待付款"),
    WAITGOODS("waitGoods",1,"待发货"),
    SHIPPED("shipped",2,"已发货"),
    FINISHED("finished",3,"已完成"),
    CLOSED("closed",4,"已关闭"),
    INVALID("invalid",5,"无效");

    /**
     * 编码
     */
    @Getter
    protected String code;

    /**
     * 值
     */
    @Getter
    protected Integer value;


    /**
     * 键
     */
    @Getter
    protected String key;

    OrderStatusEnum(String code, int value, String key) {
        this.code = code;
        this.value = value;
        this.key = key;
    }

    public static OrderStatusEnum getByValue(Integer value) {

        OrderStatusEnum baseEnum = null;

        for (OrderStatusEnum item : values()) {
            if (item.getValue().equals(value)) {
                baseEnum = item;
                continue;
            }
        }
        return baseEnum;
    }

}
